/*
 * @Descripttion: 功能清单
 * @Author: YuZhenJing
 * @Date: 2020-01-14 14:53:47
 * @LastEditors  : YuZhenJing
 * @LastEditTime : 2020-02-12 16:06:54
 */

/**
 * 查询功能清单类别数据集
 */
export function searchFunListTypeOptions() {
  const options = this.$html.get('menu/funListTypeOptions')
  options
    .then(data => {
      if (data.returnType == 'success') {
        this.funListTypeOptions = this.$objTools.dicToArray(data.returnData)
      }
    })
    .catch(() => {
      console.log('error:searchFunListTypeOptions')
    })
}

/**
 * 加载功能清单数据集
 */
export function menuTreeData() {
  const options = this.$html.get('menu/menuTreeData')
  options
    .then(data => {
      if (data.returnType == 'success') {
        this.menuData = [
          {
            funListCode: '99999999999',
            funListName: '系统功能清单',
            funListType: 'group',
            isRoot: true,
            children: data.returnData
          }
        ]
      }
    })
    .catch(() => {
      console.log('error:menu/menuTreeData')
    })
}

/**
 * 删除功能清单
 */
export function delMenu(rowObj) {
  this.$confirm('确认要删除【' + rowObj.funListName + '】吗?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  })
    .then(() => {
      const delResult = this.$html.delete('menu/delMenu', rowObj.funListCode)
      delResult
        .then(data => {
          if (data.returnType == 'success') {
            this.$notify({
              title: '成功',
              message: '删除成功',
              type: 'success'
            })
            this.menuTreeData()
          }
        })
        .catch(() => {
          console.log('error:menu/delMenu')
        })
    })
    .catch(() => {
      this.$notify.info({
        title: '消息',
        message: '已取消删除'
      })
    })
}
